package com.zhl.hadoop.cases.phonesort;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @program: demos
 * @description: 自己的类型序列化不适用java自带的序列化
 * @author: 刘振华
 * @create: 2020-10-28 10:57
 **/
public class FlowSortMapper extends Mapper<LongWritable, Text,PhoneFlowSort,Text> {

	@Override
	protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
		PhoneFlowSort flow = new PhoneFlowSort();
		Text number = new Text();
		//对每一行的数据进行处理
		String[] info = value.toString().split("\t");

		number.set(info[0]);
		flow.setUp(Integer.parseInt(info[1]));
		flow.setDown(Integer.parseInt(info[2]));
		flow.setUpAll(Integer.parseInt(info[3]));
		flow.setDownAll(Integer.parseInt(info[4]));
		context.write(flow,number);
	}
}
